#include "IVirtualBusiness.h" 
#include "Archive.h"
#include "IServlet.h"
IMP_SERIALIZE_OBJECT(Data) {
    BIND_SERIALIZE(x, 0);
    BIND_SERIALIZE(y, 1);
};

IMP_SERIALIZE_OBJECT(Information) {
    BIND_SERIALIZE(data, 0);
};

const char *IVirtualBusiness::__businessName__="IVirtualBusiness";
struct IVirtualBusiness_back_proto {
    std::string content;
};
struct IVirtualBusiness_echo_proto {
    std::string content;
};
struct IVirtualBusiness_testRemoteLogic_proto {
    int x;
    float y;
};
struct IVirtualBusiness_testRemoteLogicV1_proto {
    int x;
    double y;
    Information z;
};
IMP_SERIALIZE_OBJECT(IVirtualBusiness_back_proto) {
    BIND_SERIALIZE(content, 0);
};
IMP_SERIALIZE_OBJECT(IVirtualBusiness_echo_proto) {
    BIND_SERIALIZE(content, 0);
};
IMP_SERIALIZE_OBJECT(IVirtualBusiness_testRemoteLogic_proto) {
    BIND_SERIALIZE(x, 0);
    BIND_SERIALIZE(y, 1);
};
IMP_SERIALIZE_OBJECT(IVirtualBusiness_testRemoteLogicV1_proto) {
    BIND_SERIALIZE(x, 0);
    BIND_SERIALIZE(y, 1);
    BIND_SERIALIZE(z, 2);
};
void IVirtualBusiness::back(IServlet *servlet ,const std::string& content) {
    IVirtualBusiness_back_proto __iner__proto;
    std::string __proto_name__ = "IVirtualBusiness::back";
    __iner__proto.content=content; 
    ByteArray *out = NULL;
    Stream ss(__iner__proto,&out);
    int size = out->size();
    std::string __content;
    __content.resize(size+4+__proto_name__.size()); {
    int intS = __proto_name__.size(); memcpy(&__content[0],&intS,4);
    memcpy(&__content[4],&__proto_name__[0],__proto_name__.size());
    memcpy(&__content[4+intS],out->pointer() , size);
    servlet->request(&__content[0], __content.size());
    }
}
void IVirtualBusiness::echo(IServlet *servlet ,const std::string& content) {
    IVirtualBusiness_echo_proto __iner__proto;
    std::string __proto_name__ = "IVirtualBusiness::echo";
    __iner__proto.content=content; 
    ByteArray *out = NULL;
    Stream ss(__iner__proto,&out);
    int size = out->size();
    std::string __content;
    __content.resize(size+4+__proto_name__.size()); {
    int intS = __proto_name__.size(); memcpy(&__content[0],&intS,4);
    memcpy(&__content[4],&__proto_name__[0],__proto_name__.size());
    memcpy(&__content[4+intS],out->pointer() , size);
    servlet->request(&__content[0], __content.size());
    }
}
void IVirtualBusiness::testRemoteLogic(IServlet *servlet ,const int& x,const float& y) {
    IVirtualBusiness_testRemoteLogic_proto __iner__proto;
    std::string __proto_name__ = "IVirtualBusiness::testRemoteLogic";
    __iner__proto.x=x; 
    __iner__proto.y=y; 
    ByteArray *out = NULL;
    Stream ss(__iner__proto,&out);
    int size = out->size();
    std::string __content;
    __content.resize(size+4+__proto_name__.size()); {
    int intS = __proto_name__.size(); memcpy(&__content[0],&intS,4);
    memcpy(&__content[4],&__proto_name__[0],__proto_name__.size());
    memcpy(&__content[4+intS],out->pointer() , size);
    servlet->request(&__content[0], __content.size());
    }
}
void IVirtualBusiness::testRemoteLogicV1(IServlet *servlet ,const int& x,const double& y,const Information& z) {
    IVirtualBusiness_testRemoteLogicV1_proto __iner__proto;
    std::string __proto_name__ = "IVirtualBusiness::testRemoteLogicV1";
    __iner__proto.x=x; 
    __iner__proto.y=y; 
    __iner__proto.z=z; 
    ByteArray *out = NULL;
    Stream ss(__iner__proto,&out);
    int size = out->size();
    std::string __content;
    __content.resize(size+4+__proto_name__.size()); {
    int intS = __proto_name__.size(); memcpy(&__content[0],&intS,4);
    memcpy(&__content[4],&__proto_name__[0],__proto_name__.size());
    memcpy(&__content[4+intS],out->pointer() , size);
    servlet->request(&__content[0], __content.size());
    }
}
int IVirtualBusiness::dispatchActions(ISession *session,void *data,int size) {
    std::string name;
    int strS = *(int*)data;
    name.resize(strS);
    memcpy(&name[0],((char*)data)+4,strS);
   if (name == "IVirtualBusiness::back") {
        IVirtualBusiness_back_proto __iner__proto;
    	Stream ss(__iner__proto,((unsigned char*)data)+(strS+4),size - 4 - strS);		
        back(session,__iner__proto.content);
   }
   else if (name == "IVirtualBusiness::echo") {
        IVirtualBusiness_echo_proto __iner__proto;
    	Stream ss(__iner__proto,((unsigned char*)data)+(strS+4),size - 4 - strS);		
        echo(session,__iner__proto.content);
   }
   else if (name == "IVirtualBusiness::testRemoteLogic") {
        IVirtualBusiness_testRemoteLogic_proto __iner__proto;
    	Stream ss(__iner__proto,((unsigned char*)data)+(strS+4),size - 4 - strS);		
        testRemoteLogic(session,__iner__proto.x, __iner__proto.y);
   }
   else if (name == "IVirtualBusiness::testRemoteLogicV1") {
        IVirtualBusiness_testRemoteLogicV1_proto __iner__proto;
    	Stream ss(__iner__proto,((unsigned char*)data)+(strS+4),size - 4 - strS);		
        testRemoteLogicV1(session,__iner__proto.x, __iner__proto.y, __iner__proto.z);
   }
    return 0;
}
